﻿using System.Collections.ObjectModel;

namespace XDCCManager.Model
{
	[System.Xml.Serialization.XmlRoot("Servers")]
	[Attributes.StorageFile("ServerContext")]
	public class ServerContext : BaseModel
	{
		public ServerContext()
		{
			servers = new ObservableCollection<Servers.Server>();
			if (System.ComponentModel.LicenseManager.UsageMode == System.ComponentModel.LicenseUsageMode.Designtime)
			{
				this.Servers.Add(new Servers.Server() { Network = "Fansub-IRC", Nick = "MyGoddess", BotName = "Akia" });
				Servers.Server s = new Servers.Server() { Network = "Nanami", Nick = "MyGoddess", BotName = "Akia" };
				s.Addresses.Add(new Servers.ServerAddress() { Hostname = "irc.nanami.fr", Port = 6667, Ssl = false });
				this.Servers.Add(s);
				CurrentServer = s;
			}
		}

		private Servers.Server currentServer;

		[System.Xml.Serialization.XmlIgnore()]
		public Servers.Server CurrentServer
		{
			get { return currentServer; }
			set { if (currentServer != value) { currentServer = value; OnPropertyChanged("CurrentServer"); } }
		}

		private ObservableCollection<Servers.Server> servers;

		[System.Xml.Serialization.XmlElement("Server")]
		public ObservableCollection<Servers.Server> Servers
		{
			get { return servers; }
		}

	}
}
